﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace WebApplication1
{
    public partial class usracc : System.Web.UI.Page
    {
        string no;
        SqlConnection cnn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True");
        protected void Page_Load(object sender, EventArgs e)
        {
            no = Convert.ToString(Session["no"]);
            Label3.Text = no;
            Label3.Visible = true;
            cnn.Open();
            SqlCommand cmd = new SqlCommand("select c.name,c.lang,c.publish,c.year,d.status,d.issdate,d.expire,d.fine from account a,cdinfo c,cdissue d where d.cdno=c.cdno and d.custno=a.accno and a.accno='" + no + "'", cnn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            ds.Clear();
            da.Fill(ds, "account");
            if (ds.Tables["account"].Rows.Count <= 0)
            {
                errlabel.Visible = true;
                errlabel.Text = "No results";
                GridView1.Visible = false;
            }
            else
            {
                errlabel.Visible = false;
                GridView1.Visible = true;
                GridView1.DataSource = ds;
                GridView1.DataBind();
                SqlCommand cmd1 = new SqlCommand("select a.no_cd,a.fine from account a where a.accno='" + no + "'", cnn);
                SqlDataReader dr = cmd1.ExecuteReader();
                while (dr.Read())
                {
                    Label2.Visible = true;
                    Label4.Visible = true;
                    cdcount.Visible = true;
                    fine.Visible = true;
                    cdcount.Text = Convert.ToString(dr.GetValue(0));
                    fine.Text = Convert.ToString(dr.GetValue(1));
                }
            }
            cnn.Close();
        }
    }
}